import * as types  from '../constants/actTypes';
import { getItem } from '../utils';

const initialObject = {
    actList: [],
    curAct:{
        room:{},
        sponsor:{}
    },
    curRoom:{},
    fansList:[]
};
const initialState = getItem('act') || initialObject;
export default function act(state = initialState, action) {
    switch (action.type) {
        case types.FETCH_ACT_LIST:
            return {
                ...state,
                actList: action.actList
            };
        case types.FETCH_ACT_LIST_DETAIL:
            return {
                ...state,
                curAct: action.data.data
            };
        case types.FETCH_ACT_LIST_DETAIL_PERSON:
            return {
                ...state,
                curAct: action.data.data
            };
        case types.APPLY_ACT:
            return {
                ...state,
                curAct: action.data.data
            };
        case types.APPLY_VOL:
            return {
                ...state,
                curAct: {
                    ...state.curAct

                }
            };

        

        case types.FETCH_ROOM_INFO:
            return {
                ...state,
                curRoom:action.data.data
            };
        case types.FOLLOW_ROOM:
            return {
                ...state,
                curAct:{
                    ...state.curAct,
                    room:{
                        ...state.curAct.room,
                        isFollow: action.isFollow
                    }
                },
                curRoom: {
                    ...state.curRoom,
                    isFollow: action.isFollow
                }
            };
        case types.CANCEL_FOLLOW_ROOM:
            return {
                ...state,
                curAct:{
                    ...state.curAct,
                    room:{
                        ...state.curAct.room,
                        isFollow: action.isFollow
                    }
                },
                curRoom: {
                    ...state.curRoom,
                    isFollow: action.isFollow
                }

            };
        case types.FETCH_ROOM_FANS_LIST:
            return {
                ...state,
                fansList:action.fansList
            };

        default:
            return state;
    }
}